package com.cgbl.service.vm

import android.app.Application
import androidx.databinding.ObservableField
import com.blankj.utilcode.util.StringUtils
import com.cgbl.service.R
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.utils.JobUtil
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand

class ForgotPasswordViewModel(application: Application):GLBaseViewModel(application) {
    val codeText = ObservableField(StringUtils.getString(R.string.app_en_tips_19))
    val codeEnable = ObservableField(true)

    val sendCodeCommand = BindingCommand<Any>(BindingAction {
        setViewData()
    })


    val confirmCommand = BindingCommand<Any>(BindingAction {

    })


    private fun setViewData() {
        codeEnable.set(false)
        val job = JobUtil.countDownCoroutines(
            60, {
                codeText.set("${it}${StringUtils.getString(R.string.app_en_tips_23)}")
            },
            {
                codeText.set(StringUtils.getString(R.string.app_en_tips_20))
                codeEnable.set(true)
            }
        )
        job?.start()
    }
}